<?php


namespace backend\controllers;


use common\cache\DictCache;
use common\models\User;
use common\models\Vip;
use common\models\VipLog;

class VipController extends BaseController
{
    public function init()
    {
        parent::init();
        $this->model = Vip::className();
    }

    public function actionLog()
    {
        $this->model = VipLog::className();
        if (\Yii::$app->request->isPost){
            $data = parent::actionIndex();
            $userid = array_unique(array_column($data['data'],'userid'));
            $user = User::find()->where(['id'=>$userid])->select(['id','info'])->asArray()->all();
            $userHtml = (new User())->getUserHtml($user);
            foreach ($data['data'] as &$datum){
                $datum['user'] = $userHtml[$datum['userid']]??'';
            }
            return $data;
        }
        $status = DictCache::get('sys_viplog_status');
        \Yii::$app->view->params['status11'] = $status;
        return parent::actionIndex();
    }
}